package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ContentsMsg;
import com.ruoyi.system.service.IContentsMsgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 存放发布的内容信息Controller
 * 
 * @author whitedeer
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/system/contents_msg")
public class ContentsMsgController extends BaseController
{
    @Autowired
    private IContentsMsgService contentsMsgService;

    /**
     * 查询存放发布的内容信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContentsMsg contentsMsg)
    {
        startPage();
        List<ContentsMsg> list = contentsMsgService.selectContentsMsgList(contentsMsg);
        return getDataTable(list);
    }

    /**
     * 导出存放发布的内容信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:export')")
    @Log(title = "存放发布的内容信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContentsMsg contentsMsg)
    {
        List<ContentsMsg> list = contentsMsgService.selectContentsMsgList(contentsMsg);
        ExcelUtil<ContentsMsg> util = new ExcelUtil<ContentsMsg>(ContentsMsg.class);
        util.exportExcel(response, list, "存放发布的内容信息数据");
    }

    /**
     * 获取存放发布的内容信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:query')")
    @GetMapping(value = "/{contentId}")
    public AjaxResult getInfo(@PathVariable("contentId") Long contentId)
    {
        return success(contentsMsgService.selectContentsMsgByContentId(contentId));
    }

    /**
     * 新增存放发布的内容信息
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:add')")
    @Log(title = "存放发布的内容信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContentsMsg contentsMsg)
    {
        return toAjax(contentsMsgService.insertContentsMsg(contentsMsg));
    }

    /**
     * 修改存放发布的内容信息
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:edit')")
    @Log(title = "存放发布的内容信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContentsMsg contentsMsg)
    {
        return toAjax(contentsMsgService.updateContentsMsg(contentsMsg));
    }

    /**
     * 删除存放发布的内容信息
     */
    @PreAuthorize("@ss.hasPermi('system:contents_msg:remove')")
    @Log(title = "存放发布的内容信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentIds}")
    public AjaxResult remove(@PathVariable Long[] contentIds)
    {
        return toAjax(contentsMsgService.deleteContentsMsgByContentIds(contentIds));
    }
}
